package de.gameduell.framework.gui.builder {
	import flash.system.ApplicationDomain;

	/**
	 * @author avar
	 */
	public class DisplayObjectBuilder {

		private var _displayObjectLists:Vector.<DisplayObjectList>;

		public function DisplayObjectBuilder(displayStack:XML, domain : ApplicationDomain = null):void {
			_displayObjectLists = new Vector.<DisplayObjectList>();
			var displaydisplayStack:XMLList = displayStack..displayList;

			for(var i:uint = 0 ;i < displaydisplayStack.length(); i++) {
				var displayObjectList : DisplayObjectList = new DisplayObjectList(displaydisplayStack[i], domain);
				_displayObjectLists.push(displayObjectList);
			}
		}

		public function get displayObjectLists():Vector.<DisplayObjectList> {
			return _displayObjectLists;
		}

		public function getDisplayListById(id:String):DisplayObjectList {
			for(var i:uint = 0 ;i < _displayObjectLists.length; i++) {
				if(_displayObjectLists[i].id == id) {
					return _displayObjectLists[i];
				}
			}
			return null;
		}
	}
}
